package leecode;

import java.util.Arrays;

/**
 * 27
 *
 * @author qingyan 2021-11-30
 */
public class Question27 {

    public int removeElement(int[] nums, int val) {
        if (nums.length < 1) {
            return nums.length;
        }

        // 1,2,3,4,5,6 5
        // 1,2,3,4,6,5 5
        // 1,2,2,2,4,5,5
        // 1,4,2,2,2,5,5
        // 1,4,
        int j = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                nums[j++] = nums[i];
            }
        }
        return j;

    }

    public static void main(String[] args) {
        Question27 question27 = new Question27();
        int[] nums = new int[]{2};
        int len = question27.removeElement(nums, 2);
        for (int j = 0; j < len; j++) {
            System.out.println(nums[j]);
        }
    }
     // 计算符
}
